package cn.inyaa.admin.sys.controller;

import cn.inyaa.admin.sys.bean.InyaaSysPermission;
import cn.inyaa.admin.sys.service.InyaaSysPermissionService;
import cn.inyaa.admin.sys.vo.InyaaSysPermissionVo;
import com.inyaa.base.bean.BaseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: yuxh
 * @date: 2021/3/4 0:13
 */
@RestController
@RequestMapping("/permission")
@RequiredArgsConstructor
public class InyaaSysPermissionController {

    private final InyaaSysPermissionService inyaaSysPermissionService;

    @GetMapping("/list")
    public BaseResult<List<InyaaSysPermission>> list(InyaaSysPermission permission) {
        return BaseResult.success(inyaaSysPermissionService.findMenuList(permission));
    }

    @GetMapping("/findMenuList")
    public BaseResult<List<InyaaSysPermissionVo>> findMenuList(Integer enable) {
        return BaseResult.success(inyaaSysPermissionService.findMenuList(enable));
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public BaseResult<String> save(@RequestBody InyaaSysPermission permission) {
        inyaaSysPermissionService.save(permission);
        return BaseResult.success();
    }

    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public BaseResult<String> delete(@RequestBody InyaaSysPermission permission) {
        inyaaSysPermissionService.delete(permission);
        return BaseResult.success();
    }
}
